home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte22 / ex10.c < prev    next >
C/C++ Source or Header  |  1995-05-29  |  3KB  |  69 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_COMMAND:
  8.                switch ( LOWORD( wParam ) )
  9.                {
  10.                      case IDM_TEST:
  11.                      {
  12.                         int   i, iBytesCopied;
  13.                         HFONT hOldFont;
  14.                         TCHAR szBuffer[96];
  15.                         TCHAR szXlatBuffer[33];
  16.                         TCHAR szAccentedChars[33];
  17.                         HDC   hDC = GetDC( hWnd );
  18.  
  19.                         // Make an ANSI string of characters to translate,
  20.  
  21.                         for (i=0; i<0x10; i++)
  22.                            szAccentedChars[i] = 0xc0 + i; // c0 to cf
  23.                         for (i=0x10; i<0x20; i++)
  24.                            szAccentedChars[i] = 0xd0 + i; // e0 to ef
  25.                         szAccentedChars[0x20] = 0;
  26.  
  27.                         hOldFont = SelectObject( hDC,
  28.                                                  GetStockObject( ANSI_FIXED_FONT ) );
  29.  
  30.                         wsprintf( szBuffer, "Original Buffer:  %s", szAccentedChars );
  31.                         TextOut( hDC, 0, 0, szBuffer, lstrlen( szBuffer ) );
  32.  
  33.                         iBytesCopied = LCMapString( LOCALE_USER_DEFAULT,
  34.                                                     LCMAP_UPPERCASE,
  35.                                                     szAccentedChars, -1,
  36.                                                     szXlatBuffer, 33 );
  37.                         if (iBytesCopied)
  38.                         {
  39.                            wsprintf( szBuffer, "Uppercase Buffer: %s", szXlatBuffer );
  40.                            TextOut( hDC, 0, 20, szBuffer, lstrlen( szBuffer ) );
  41.                         }
  42.  
  43.                         iBytesCopied = LCMapString( LOCALE_USER_DEFAULT,
  44.                                                     LCMAP_LOWERCASE,
  45.                                                     szAccentedChars, -1,
  46.                                                     szXlatBuffer, 33 );
  47.                         if (iBytesCopied)
  48.                         {
  49.                            wsprintf( szBuffer, "Lowercase Buffer: %s", szXlatBuffer );
  50.                            TextOut( hDC, 0, 40, szBuffer, lstrlen( szBuffer ) );
  51.                         }
  52.  
  53.                         DeleteObject( SelectObject( hDC, hOldFont ) );
  54.                         ReleaseDC( hWnd, hDC );
  55.                      }
  56.                      break;
  57.                      case IDM_EXIT:
  58.                            DestroyWindow( hWnd );
  59.                      break;
  60.                }
  61.                break;
  62.          case WM_DESTROY:
  63.                PostQuitMessage( 0 );
  64.                break;
  65.          default:
  66.                return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  67.    }
  68.    return( NULL );
  69. }